const userDB = [
    {
        username: 'admin',
        password: 'admin',
        uuid: 'admin-uuid',
        userinfo: {
            nickname: 'Aresn',
            mobile: "18681555555",
            // avatar: '',
            // email: "",
            id: 1,
            // access: ['admin']
        }
    },
    {
        username: 'user',
        password: 'user',
        uuid: 'user-uuid',
        userinfo: {
            nickname: 'user',
            // mobile: "18681555555",
            // avatar: '',
            // email: "",
            id: 2,
            // access: ['user']
        }
    }
];

import { routersData, sliders } from './routers';
export default [
    {
        path: '/api/login',
        method: 'post',
        handle ({ body }) {
            const user = userDB.find(e => {
                return e.username === (body.username||body.mobile) && e.password === body.password
            });
            if (user) {
                return {
                    code: "200",  
                    msg: '登录成功',
                    data: {
                        ...user,
                        token: "eyJpdiI6Ii9YQVB6WWl1M0lKYWF1NldzZXZPTnc9PSIsInZhbHVlIjoiYzBLOFI2MnZQNTJ0T1BFWHVnODcxVmpNa3JudUpJUzA3VldpMTIvekJRdzZpdThuS2FodGFINmxETDB1MHpqKzlFb0MyN3J1ZU5Femc5ZFIvdUxOZ2c9PSIsIm1hYyI6IjUwNTJjMWIxZGM1OGEwNTg4OTA5YmI5ZjZmYzI2Mzk1ZDJiMWI5OTMxOTMyMmY1YWQ3YTkxNWNmZjRiZjE2NGQifQ=="
                    }
                }
            } else {
                return {
                    code: "434",
                    msg: '用户名或密码错误',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/register',
        method: 'post',
        handle ({ body }) {
            return {
                code: 0,
                msg: '注册成功',
                data: {
                    username: 'admin',
                    uuid: 'admin-uuid',
                    info: {
                        name: 'Aresn',
                        avatar: 'https://dev-file.iviewui.com/userinfoPDvn9gKWYihR24SpgC319vXY8qniCqj4/avatar',
                        access: ['admin']
                    },
                    token: 'A68NUPaXVBJYRStwvd9frcUn8rlf30h6'
                }
            }
        }
    },
    {
        path: '/api/routersData',
        method: 'post',
        handle ({ body }) {
            return {
                code: 0,
                msg: '路由表请求成功',
                data: {
                    username: 'admin',
                    uuid: 'admin-uuid',
                    routersData,
                    sliders,
                    token: 'A68NUPaXVBJYRStwvd9frcUn8rlf30h6'
                }
            }
        }
    }
]
